/*
 * Copyright (C) 2013 rdrrlabs gmail com,
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.rdrrlabs.example.timer2app.pub.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.rdrrlabs.example.timer2app.R;

public class IntroFragment extends Fragment {

    private TextView mTextSignInfo;
    private Button mBtnSignInOut;
    private Button mBtnEvents;
    private Button mBtnSettings;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);
    }

    @Override
    public View onCreateView(
                    LayoutInflater inflater,
                    ViewGroup container,
                    Bundle state) {
        View root = inflater.inflate(R.layout.fragment_intro, container, false);

        mTextSignInfo = (TextView) root.findViewById(R.id.textAccountName);
        mBtnSignInOut = (Button) root.findViewById(R.id.btnSignInOut);
        mBtnEvents    = (Button) root.findViewById(R.id.btnEvents);
        mBtnSettings  = (Button) root.findViewById(R.id.btnSettings);

        mBtnSignInOut.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SignInDialog.showSignInDialog(getActivity());
            }
        });

        mBtnEvents.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickProfiles();
            }
        });

        mBtnSettings.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickSettings();
            }
        });

        return root;
    }

    @Override
    public void onResume() {
        super.onResume();
        mTextSignInfo.setText(R.string.intro__not_logged);
    }

    protected void onClickProfiles() {
        startActivity(new Intent(getActivity(), EventListActivity.class));
    }

    protected void onClickSettings() {
        startActivity(new Intent(getActivity(), SettingsActivity.class));
    }
}
